home *** CD-ROM | disk | FTP | other *** search
- UNIT STATUS;
-
- interface
- uses wobjects, wintypes,winprocs;
- type
- pStatusBar = ^TStatusBar;
- TStatusBar = object(Twindow)
- CurrentID : integer;
- childHeight : integer;
- hmenuSystem : HMENU;
- hmenufile : Hmenu;
- hmenuEdit : hmenu;
- constructor Init(AParent: PWindowsObject);
- function GetClassName: PChar; virtual;
- procedure SetupWindow; virtual;
- procedure GetWindowClass(var AWndClass:TWndClass); virtual;
- Procedure Adjustsize(parentWidth, ParentHeight : word);
- procedure DisplayString(resourceID :integer);
- procedure WMMenuSelect(var MSG : TMessage); virtual
- WM_FIRST + WM_Menuselect;
- procedure Paint(PaintDC: HDC; var PaintInfo: TPaintStruct); virtual;
- end;
- implementation
-
- constructor TStatusBar.init(Aparent : pwindowsobject);
- begin
- TWindow.init(Aparent,'');
- Attr.Style := WS_Child + WS_Visible + WS_border;
- Attr.x := 0;
- Attr.y := 0;
- Attr.w := 0;
- attr.h := 0;
- currentID := 0;
- if (Aparent = nil) then
- Status := EM_INVALIDCHILD;
- end;
-
- procedure TStatusBar.SetupWindow;
- var
- sbdc : HDC;
- tm : TTextMetric;
- ParMenu : Hmenu;
- begin
- Twindow.setupwindow;
- sbdc := GetDC(Hwindow);
- GetTextMetrics(sbdc, tm);
- ReleaseDC(Hwindow,sbdc);
- childheight := tm.tmheight + (tm.tmheight DIV 3);
- ParMenu := GetMenu(hwnd(Parent));
- hmenuSystem :=GetSystemMenu(hwnd(Parent),FALSE);
- hmenufile :=GetSubMenu(ParMenu,0);
- hmenuEdit := GetSubMenu(Parmenu,1);
- end;
- function TStatusBar.GetClassName: PChar;
- begin
- GetClassName := 'TStatusBar';
- end;
-
- procedure TStatusBar.GetWindowClass(var AWndClass : TWndClass);
- begin
- Twindow.GetWindowClass(AWndClass);
- AwndClass.hbrBackground := GetStockObject(LTGRAY_BRUSH);
- end;
-
- Procedure TStatusBar.Adjustsize(parentWidth, ParentHeight : word);
- var
- x,y : integer;
- begin
- x := 0;
- y := parentHeight - childHeight + 1;
- MoveWindow(HWindow, x,y,parentWidth,ChildHeight,TRUE);
- end;
-
- procedure TStatusBar.WMMenuSelect(var MSG : TMessage);
- var
- wIDItem,fwMenu : Hmenu;
- hMen : HMenu;
- resourceID : integer;
- menuClosing : Boolean;
- begin
- wIDItem := msg.WParam;
- fwMenu := msg.LParamLo;
- hmen := msg.LParamHi;
- resourceID := 0;
-
- menuClosing := ((fwMenu = $0ffff) AND (hmen = 0));
-
- if (fwMenu AND MF_POPUP)<> 0 then
- begin
- if wIDItem = hmenuSystem then
- resourceID := 1
- else if wIDItem = hmenuFile then resourceID := 2
- else if wIDItem = hmenuEdit then resourceID := 3;
- end
- else
- if (menuClosing = FALSE)then
- resourceID := wIDItem;
-
- DisplayString(resourceID);
- end;
-
- procedure TStatusBar.DisplayString(resourceID :integer);
- var
- r : TRECT;
- s : array [0..128] of char;
- hdci : hdc;
- begin
- s[0] := #0;
- if resourceID <> 0 then
- begin
- LoadString(hinstance,resourceID,s,sizeof(s));
- end;
- currentID := resourceID;
- GetClientRect(hwindow, R);
- hdci := GETDC(HWindow);
- OffsetRect(r,1,1);
- FillRect(hdci,r,GetStockObject(LTGRAY_BRUSH));
- FrameRect(hdci,r,GetStockObject(DKGRAY_BRUSH));
-
-
- OffsetRect(r,-1,-1);
- FrameRect(hdci,r,GetStockObject(WHITE_BRUSH));
- setbkmode(hdci,TRANSPARENT);
- EXTTextOut(hDCi,4,0,ETO_CLIPPED,@r,s,lstrlen(s),nil);
- releasedc(hwindow,hdci);
- end;
-
- procedure TStatusBar.Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
- begin
- DisplayString(currentID);
- end;
-
- end.